package com.example.jdshopdetailtwo.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.jdshopdetailtwo.R;
import com.example.jdshopdetailtwo.bean.ShopDetailModel;
import com.example.jdshopdetailtwo.util.GlideUtils;

import java.util.List;

/**
 * 作者： njb
 * 时间： 2018/10/17 0017-下午 5:32
 * 描述： 产品相关商品适配器
 * 来源：
 */
public class RelatedProductAdapter extends BaseQuickAdapter<ShopDetailModel, BaseViewHolder> {
    public RelatedProductAdapter(@Nullable List<ShopDetailModel> data) {
        super(R.layout.item_product_shop,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopDetailModel item) {
        //商品名称
        helper.setText(R.id.tv_shop_name, item.getGoods_name());
        //本商场售价
        helper.setText(R.id.tv_shop_price, "￥" +item.getShop_price());
        if (item.getGoods_spec() != null && !item.getGoods_spec().equals("0")) {
            //规格
            helper.setText(R.id.tv_shop_format, item.getGoods_spec());
        }

        //原图
        GlideUtils.loadImg(mContext, item.getGoods_img(), (ImageView) helper.getView(R.id.iv_shop_img), R.mipmap.good_default, 240, 240);


        helper.addOnClickListener(R.id.iv_shop_to_cart);
    }
}
